package com.edu.controller;

import com.edu.bean.Page;
import com.edu.service.GoodsService;
import com.edu.service.impl.GoodsServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @Author:xgdxqr
 * @Date:2025/9/19-15:30-48
 **/

@WebServlet("/delete.do")
public class DeleteGoodsServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        GoodsService goodsService = new GoodsServiceImpl();
        Page page = null;
        int goodsId;
        try {
            goodsId = Integer.parseInt(req.getParameter("goodsId"));
            goodsService.deleteById(goodsId);
        } catch (Exception e) {
            System.out.println("删除失败");
        }
        req.getRequestDispatcher("getGoods.do").forward(req, resp);
    }
}
